﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

public partial class UserControl_Top3Advertis : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        StringBuilder sb = new StringBuilder();
        sb.Append("<script type='text/javascript'>");
        sb.Append("var advFooter = new fadeSlideShow({wrapperid: 'advFooter',dimensions: [670, 60],imagearray: [");
        using (Up1VNDataContext dc = new Up1VNDataContext())
        {
            var top1 = from o in dc.UsersAdvs
                       where o.UsersAdv_Location == "footer" && o.UsersAdv_ToDate > DateTime.Now && o.UsersAdv_Status == (long)2
                       select o;
            if (top1.Count() > 0)
            {
                foreach (var item in top1)
                {
                    sb.Append("['" + ResolveUrl("~/images/Advertis/" + item.UsersAdv_PicturePath) + "','" + item.UsersAdv_Id + "/Thongtindoanhnghiep.html','','<a href=\"" + ResolveUrl("~/footer/Dangquangcao.html") + "\">Đăng quảng cáo</a>'],");
                }
            }
            else
            {
                sb.Append("['" + ResolveUrl("~/images/add_avertis.gif") + "','','','<a href=\"" + ResolveUrl("~/footer/Dangquangcao.html") + "\">Đăng quảng cáo</a>'],");
            }
        }
        sb.Append("],displaymode: { type: 'auto', pause: 3000, cycles: 0, wraparound: false },persist: false,fadeduration: 500,descreveal: 'ondemand',togglerid: ''})");
        sb.Append("</script>");
        ltrfooter.Text = sb.ToString();
    }
}